#ifndef recordFileMonitor_H
#define recordFileMonitor_H

#include<iostream>
#include <map>
#include<string>
#include<sys/statfs.h>
#include<sys/stat.h>
#include "Util/File.h"
#include "Util/util.h"
#include<future>
#include<atomic>
#include<ctime>
#include"Poller/Timer.h"
#include"Util/logger.h"
#include"Common/config.h"
using namespace toolkit;
using namespace mediakit;
class videoPlatformApplication {
public:
    using Ptr = std::shared_ptr<videoPlatformApplication>;
    static Ptr getInstance(){
        if (p_instance==nullptr){
            std::lock_guard<std::mutex>lck(videoPlatformApplication_mtx);
            if (p_instance==nullptr){
                p_instance=std::shared_ptr<videoPlatformApplication>(new videoPlatformApplication());
                init();
            }
        }
        return p_instance;
    }
    void  diskSpaceMonitor();
    void  recordTimeMonitor();
    int deleteRecordFile(std::string recordFilePath="");
    std::mutex record_file_map_mtx;
    static std::multimap<time_t,std::string> _record_file_map;
    ~videoPlatformApplication();
    void deleteFileByRecordTime();
private:
    static int init();
    static Ptr p_instance;
    static std::string _dir;
    static std::mutex videoPlatformApplication_mtx;
    std::future<void> diskMonitorFuture;
    std::future<void> MaxtimeFuture;
};

#endif
